<?php
function cookie_check(){
    if(!isset($_COOKIE['username'])){
        return	redirect('Index/login');
    }
}
function ajax_data($code=0,$message='成功',$data=NULL){
    return ['code'=>$code,'message'=>$message,'data'=>$data];
}
function passwd($pwd){
    $salt = 'zibenlifang';
    return md5($salt.$pwd.$salt);
}
function checkCookie(){
    if (cookie('code') === md5(cookie('username').'admin123')) {
        return 1;
    } else {
        echo "<script type=text/javascript>window.open('/','_parent');window.close();</script>";
        return  redirect('/Admin/Index/login');
        return 0;
    }
}
function footer(){
    $sys = M('sys')->where('sid=1')->find();
    return $sys;
}

if (!function_exists('wx_share_init')) {
    function wx_share_init($url = '') {
        $wxconfig = array();
        Vendor('Wxshare.class#jssdk');
        $jssdk = new JSSDK(C("AppID"),C("AppSecret"), $url);
        $wxconfig = $jssdk->GetSignPackage();
        return $wxconfig;
    }
}
?>